package cn.iocoder.yudao.module.social.convert.content;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.social.controller.admin.content.vo.ContentCreateReqVO;
import cn.iocoder.yudao.module.social.controller.admin.content.vo.ContentUpdateReqVO;
import cn.iocoder.yudao.module.social.controller.app.content.vo.AppContentCreateReqVO;
import cn.iocoder.yudao.module.social.controller.app.content.vo.AppContentRespVO;
import cn.iocoder.yudao.module.social.controller.app.content.vo.AppContentUpdateReqVO;
import cn.iocoder.yudao.module.social.dal.dataobject.content.ContentDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 用户端内容 Convert
 *
 * @author 芋道源码
 */
@Mapper
public interface AppContentConvert {

    AppContentConvert INSTANCE = Mappers.getMapper(AppContentConvert.class);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "authorId", ignore = true)
    ContentDO convert(AppContentCreateReqVO bean);

    @Mapping(target = "authorId", ignore = true)
    ContentDO convert(AppContentUpdateReqVO bean);

    AppContentRespVO convert(ContentDO bean);

    List<AppContentRespVO> convertList(List<ContentDO> list);

    PageResult<AppContentRespVO> convertPage(PageResult<ContentDO> page);

    // 转换为管理端 VO
    @Mapping(target = "authorId", source = "authorId")
    ContentCreateReqVO convertToAdmin(AppContentCreateReqVO bean, Long authorId);

    ContentUpdateReqVO convertToAdmin(AppContentUpdateReqVO bean);

}
